package com.cskaoyan.bean.vo;

import com.cskaoyan.bean.po.MarketCoupon;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class AdminCouponListVo {
    /**
     * total : 3
     * pages : 1
     * limit : 20
     * page : 1
     * list : [{"addTime":"2022-09-07 14:47:21","discount":1,"timeType":0,"goodsValue":[],"updateTime":"2022-09-07 14:47:21","type":0,"goodsType":0,"total":11111,"min":111,"deleted":false,"name":"ceshi3","limit":1,"days":1,"id":17,"tag":"11111","desc":"111","status":0},{"addTime":"2022-09-07 14:36:14","discount":0,"timeType":0,"goodsValue":[],"updateTime":"2022-09-07 14:36:14","type":0,"goodsType":0,"total":0,"min":0,"deleted":false,"name":"ceshi1","limit":1,"days":0,"id":15,"tag":"","desc":"","status":0}]
     */
    private int total;
    private int pages;
    private int limit;
    private int page;
    private List<ListEntity> list = new ArrayList<>();

    //提供构造list的方法
    /*public void setCouponList(Date addTime, BigDecimal discount, Short timeType, String goodsValues, Date updateTime,
                              Short type, Short goodsType, Short total, BigDecimal min, Boolean deleted, String name,
                              Short limit, Short days, Integer id, String tag, String desc, Short status){
        ListEntity listEntity = new ListEntity();
        listEntity.setAddTime(addTime);
        listEntity.setDiscount(discount);
        listEntity.setTimeType(timeType);
//        listEntity.setGoodsValue(goodsValue);
        listEntity.setUpdateTime(updateTime);
        listEntity.setType(type);
        listEntity.setGoodsType(goodsType);

        if(goodsType == 0){
            //goods_type如果是0则空集合
            List<Object> goodsValue = new ArrayList<>();
            listEntity.setGoodsValue(goodsValue);
        }else if(goodsType == 1){
            //如果是1则是类目集合
            System.out.println("暂无数据");
        }else{
            //如果是2则是商品集合
            System.out.println("暂无数据");
        }

        listEntity.setTotal(total);
        listEntity.setMin(min);
        listEntity.setDeleted(deleted);
        listEntity.setName(name);
        listEntity.setLimit(limit);
        listEntity.setDays(days);
        listEntity.setId(id);
        listEntity.setTag(tag);
        listEntity.setDesc(desc);
        listEntity.setStatus(status);
        list.add(listEntity);
    }*/

    public void setCouponList(MarketCoupon marketCoupon){
        ListEntity listEntity = new ListEntity();
        BeanUtils.copyProperties(marketCoupon,listEntity);
        list.add(listEntity);
    }


    @Data
    public class ListEntity {
        /**
         * addTime : 2022-09-07 14:47:21
         * discount : 1.0
         * timeType : 0
         * goodsValue : []
         * updateTime : 2022-09-07 14:47:21
         * type : 0
         * goodsType : 0
         * total : 11111
         * min : 111.0
         * deleted : false
         * name : ceshi3
         * limit : 1
         * days : 1
         * id : 17
         * tag : 11111
         * desc : 111
         * status : 0
         */
        private Date addTime;
        private BigDecimal discount;
        private short timeType;
        private List<?> goodsValue = new ArrayList<>();
        private Date updateTime;
        private short type;
        private short goodsType;
        private short total;
        private BigDecimal min;
        private boolean deleted;
        private String name;
        private short limit;
        private short days;
        private int id;
        private String tag;
        private String desc;
        private short status;
        private Date startTime;
        private Date endTime;
    }
}
